package com.yuxi.Request;

import java.io.Serializable;
import java.util.List;
/** 
 *
 */
public class Page<T extends Serializable>{
	private List<T> list;
	private int totalRow;
	private int totalPage;
	private int currentPage;
	private int pageSize;
	private boolean isFirstPage;
	private boolean isLastPage;
	private boolean hasPreviusPage;
	private boolean hasNextPage;
	
	
	public void setLastPage(boolean isLastPage) {
		this.isLastPage = isLastPage;
	}
	public void setHasPreviusPage(boolean hasPreviusPage) {
		this.hasPreviusPage = hasPreviusPage;
	}
	public void setHasNextPage(boolean hasNextPage) {
		this.hasNextPage = hasNextPage;
	}
	public Page(){
		this.currentPage=1;
		this.pageSize=10;
	}
	public List<T> getList() {
		return list;
	}
	public void setList(List<T> list) {
		this.list = list;
	}
	public int getTotalRow() {
		return totalRow;
	}
	public void setTotalRow(int totalRow) {
		this.totalRow = totalRow;
		this.totalPage=totalRow%pageSize==0?totalRow/pageSize:(totalRow/pageSize)+1;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
		
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public boolean isFirstPage() {
		return currentPage==1;
	}
	public void setFirstPage(boolean isFirstPage) {
		this.isFirstPage = isFirstPage;
	}
	public boolean isLastPage() {
		return currentPage==totalPage;
	}
	
	public boolean isHasPreviusPage() {
		return currentPage>1;
	}
	
	public boolean isHasNextPage() {
		return currentPage<totalPage;
	}
	@Override
	public String toString() {
		return "Page [list=" + list + ", totalRow=" + totalRow + ", totalPage="
				+ totalPage + ", currentPage=" + currentPage + ", pageSize="
				+ pageSize + ", isFirstPage=" + (currentPage==1) + ", isLastPage="
				+ (currentPage==totalPage) + ", hasPreviusPage=" + (currentPage>1)
				+ ", hasNextPage=" + (currentPage<totalPage) + "]";
	}

	
	
}
